/*
 * Copyright 2017 Baiyyy
 * @(#)WorkingState.java
 */

package com.byyy.ccts.modules.ysjl.enums;

/**
 * 工作状态枚举
 */
public enum UserRankEnum implements EnumInterface  {

    RANKONE(1, "萌萌小新"),
    RANKTWO(2, "初出茅庐"),
    RANKTHREE(3, "小悟空"),
    RANKFOUR(4, "弗利萨"),
    RANKFIVE(5, "超赛"),
    RANKSIX(6, "破坏神"),
    ;
    private int code;
    private String msg;

    private UserRankEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static UserRankEnum getEnumByCode(int code) {
        for (UserRankEnum c : values()) {
            if (c.getCode() == code) {
                return c;
            }
        }
        return null;
    }

    public static String getMsgByCode(int code) {
        for (UserRankEnum c : values()) {
            if (c.getCode() == code) {
                return c.getMsg();
            }
        }
        return null;
    }

    /**
     * getByMsg
     *
     */
    public static UserRankEnum getByMsg(String msg) {
        for (UserRankEnum c : values()) {
            if (c.msg.equals(msg)) {
                return c;
            }
        }
        return null;
    }

    public static Integer getCodeByMsg(String msg) {
        for (UserRankEnum c : UserRankEnum.values()) {
            if (c.msg.equals(msg)) {
                return c.code;
            }
        }
        return null;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }


    public String getKey() {
        return this.name();
    }
}
